import React, {Component} from 'react';
import './index.css';
// import C from '../1_setState';
export default class Index extends Component {
	render() {
		return (
			<div className="parent">
				<h3>我是Parent组件</h3>
				{/* 给A组件传的是一个 renderProps 相当于Vue中的插槽！！！ */}
				<A render={(name) => <B name={name}/>} />
			</div>
		);
	}
}

class A extends Component {
	state = {name: "tom"};
	render() {
		const {name} = this.state;
		return (
			<div className="a">
				<h3>我是A组件,{this.state.name}</h3>
				{this.props.render(name)}
			</div>
		);
	}
}

class B extends Component {
	render() {
		return (
			<div className="b">
				<h3>我是B组件, {this.props.name}</h3>
			</div>
		);
	}
}